package com.java;

import java.util.Scanner;


/**
 *
 * @author chen52
 */
public class Starter {
    // 批测试用的表达式
    static String[] testExpression = new String[] {
            "5 2",
            "2 sqrt",
            "clear 9 sqrt",
            "5 2 -",
            "3 -",
            "clear",
            "5 4 3 2",
            "undo undo *",
            "5 *",
            "undo",
            "7 12 2 /",
            "*",
            "4 /",
            "1 2 3 4 5 *",
            "clear 3 4 -",
            "1 2 3 4 5",
            "* * * *",
            "1 2 3 * 5 + * * 6 5"
    };

    static String[] testBigExpression = new String[] {
            "123456789098765432123456789 9 +",
            "123456789098765432123456789 sqrt",
    };


    @SuppressWarnings("resource")
    public static void main(String args[]) {
        Calculator calculator = new Calculator();
        boolean flag = true;// 是否测试
        try {
            while (true) {
                // 使用批量表达式测试
                if (flag) {
                    for (String str : testExpression) {
                        System.out.println("请输入表达式 - 测试： " + str);
                        calculator.doExpression(str);
                    }
                    flag = false;
                }
                // 手动输入表达式测试
                System.out.println("手动输入表达式测试：");
                Scanner scanner = new Scanner(System.in);
                String scan = scanner.nextLine();
                System.out.println("表达式： " + scan);
                calculator.doExpression(scan);
            }

        } catch (ExpressionFormatException e) {
            e.printStackTrace();
        }
    }
}